package com.timber.login;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import com.borland.jbcl.layout.*;
import com.timber.util.*;

import javax.swing.border.*;


public class LoginConfirmation extends JDialog
{

  String loginDate;
  protected BorderLayout borderLayout1 = new BorderLayout();
  protected JPanel pButtons = new JPanel();
  protected JButton jButton1 = new JButton();
  protected JLabel l2 = new JLabel();
  protected JLabel l3 = new JLabel();
  public LoginConfirmation(String date)
  {
    loginDate = date;
    try {
      jbInit();
      setSize(300, 100);
      pack();
      Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
      int screenHeight = d.height;
      int screenWidth = d.width;
      int myWidth = getWidth();
      int myHeight = getHeight();
      setLocation( ( screenWidth - myWidth ) / 2,
		   ( screenHeight - myHeight ) / 2 );

    }
    catch(Exception e) {e.printStackTrace(); }
  }
  protected SLImageButton btn = new SLImageButton("Test");
  protected JPanel jPanel1 = new JPanel();
  protected GridBagLayout gridBagLayout1 = new GridBagLayout();
  protected JLabel jLabel1 = new JLabel();
  protected JPanel pParent = new JPanel();
  protected Border border1;

  private void jbInit() throws Exception
  {

    this.getRootPane().setDefaultButton(jButton1);
    pParent = (JPanel)this.getContentPane();
    border1 = BorderFactory.createEtchedBorder(Color.white,new Color(134, 134, 134));
    pParent.setLayout(borderLayout1);


    btn.setText("");
    btn.setEnabled(false);
    btn.setPreferredSize(new Dimension(90, 60));
    btn.setImageAt( ImageMgr.getIcon( ImageMgr.WARNING_ICON ).getImage(), 0 );
    jButton1.setFont(new java.awt.Font("Dialog", 1, 11));
    jButton1.setText("Ok");
    jButton1.addActionListener(new java.awt.event.ActionListener()
    {
      public void actionPerformed(ActionEvent e)
      {
        jButton1_actionPerformed(e);
      }
    });
    //javax.swing.ImageIcon icon = new javax.swing.ImageIcon(ImageMgr.getIcon( ImageMgr.FUNNEL_ICON ).getImage());
    //l1.setIcon(icon);
    l2.setFont(new java.awt.Font("Dialog", 1, 11));
    l2.setForeground(Color.black);
    if (loginDate.startsWith("1900"))
      l2.setText("First time logging into iDelta.");
    else
    {
      l2.setText("Last successful login on " +  loginDate + ".");
      l3.setFont(new java.awt.Font("Dialog", 1, 11));
      l3.setForeground(Color.black);
      l3.setText("Please contact your security");
      jLabel1.setFont(new java.awt.Font("Dialog", 1, 11));
      jLabel1.setForeground(Color.black);
      jLabel1.setText("administrator if this is not correct.");
      jPanel1.setLayout(gridBagLayout1);
    }
    jPanel1.setPreferredSize(new Dimension(310, 90));
    this.setTitle("IDelta Warning");

    pParent.setBorder(border1);
    pParent.add(pButtons, BorderLayout.SOUTH);
    pButtons.add(jButton1, null);
    pParent.add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(l3, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(l2, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jLabel1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(btn, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

  }

  void jButton1_actionPerformed(ActionEvent e)
  {
    this.setVisible( false );
  }
}